public class demo1 {
    public int getMost(int[][] board) {
        // write code here
        int[][] maxVal = new int[board.length][board[0].length];
        for (int i = 0; i < maxVal.length; i++) {
            if (i == 0) {
                maxVal[i][0] = board[i][0];
            } else {
                maxVal[i][0] = board[i][0] + maxVal[i - 1][0];
            }
        }
        for (int i = 0; i < maxVal[0].length; i++) {
            if (i == 0) {
                maxVal[0][i] = board[0][i];
            } else {
                maxVal[0][i] = board[0][i] + maxVal[0][i - 1];
            }
        }
        for (int i = 1; i < maxVal.length; i++) {
            for (int j = 1; j < maxVal[0].length; j++) {
                maxVal[i][j] = Math.max(maxVal[i - 1][j], maxVal[i][j - 1]) + board[i][j];
            }
        }
        return maxVal[maxVal.length - 1][maxVal[0].length - 1];
    }
}
